#include "StelLogger.hpp"

#include <QDateTime>
#include <QProcess>
#ifdef Q_OS_WIN
#include <windows.h>
#endif

QFile StelLogger::logFile;
QString StelLogger::log;

void StelLogger::init(cost QString& logFilePath)
{
	logFile.setFileName(logFilePath);
	
	if (logFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text | QIODevice::Unbuffered))
		qInstallMsgHandler(StelLogger::debugLogHandler);
		
	writeLog(QString("%1").arg(QDateTime::currentDateTime().toString(Qt::ISODate)));
	
#ifdef Q_OS_WIN
	switch(QSysInfo::WindowsVersion)
	{
		case QSysInfo::WV_95:
			writeLog("Windows 95");
			break;
		case QSysInfo::WV_98:
			writeLog("Windows 98");
			break;
		case QSysInfo::WV_Me:
			writeLog("Windows Me");
			break;
		case QSysInfo::WV_NT:
			writeLog("Windows NT");
			break;
		case QSysInfo::WV_2000:
			writeLog("Windows 2000");
			break;
		case QSysInfo::WV_XP:
			writeLog("Windows XP");
			break;
	}
#elif defined Q_OS_MAC
#elif defined Q_OS_LINUX
#else
#endif
}
